﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SystemManager.Controllers
{
    public class VoiceController : Controller
    {
        private VolumeControl volumeControl = VolumeControl.Instance;

        public ActionResult Current()
        {
            var i = volumeControl.MasterVolume;
            return Json(new { voice = i, isMute = volumeControl.IsMute });
        }

        public ActionResult Change(string action)
        {
            var i = volumeControl.MasterVolume;
            if (action == "+")
            {
                i++;
            }
            else
            {
                i--;
            }
            volumeControl.MasterVolume = i;
            return Json(new { voice = i, isMute = volumeControl.IsMute });
        }

        public ActionResult Update(uint voice)
        {
            volumeControl.MasterVolume = voice;
            var i = volumeControl.MasterVolume;
            return Json(new { voice = i, isMute = volumeControl.IsMute });
        }

        public ActionResult Mute(bool isMute)
        {
            volumeControl.IsMute = isMute;
            return Json(new { voice = volumeControl.MasterVolume, isMute = volumeControl.IsMute });
        }

    }
}
